* BFW.DO   January 2008 for Stata version 9.0

log using bfw_final.txt, text replace

********** OVERVIEW OF BFW.DO **********

STATA Program 
* used for "Exchange Rate Policy Attitudes: Direct Evidence from Survey Data" 
* by J. Lawrence Broz, Jeff Frieden, and Stephen Weymouth (2008)
* IMF Staff Papers 

use bfw_final, clear

********************
**** Regressions****
********************

****************
Floating Regimes
*****************

***LYS==1 Floats***
use bfw_final, clear
keep if fx_3way_99==1
 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)
 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact     , cluster(country)
 oprobit  fx_prob   tradeable govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99     , cluster(country)
 oprobit  fx_prob   export  govt_own size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)

***RR Floats***
use bfw_final, clear
keep if   rr_regime_99==3|rr_regime_99==4
drop if country=="Indonesia"
 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)
 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact     , cluster(country)
 oprobit  fx_prob   tradeable govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99     , cluster(country)
 oprobit  fx_prob   export  govt_own size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)

*******************
*Pegged Regimes*
******************

**LYS Pegs***
use bfw_final, clear
keep if fx_3way_99==3
 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)
 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact     , cluster(country)
 oprobit  fx_prob   tradeable govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99     , cluster(country)
 oprobit  fx_prob   export  govt_own size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)

***RR Peg***
use bfw_final, clear
keep if  rr_regime_99==1

 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)
 oprobit  fx_prob   govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact     , cluster(country)
 oprobit  fx_prob   tradeable govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99     , cluster(country)
 oprobit  fx_prob   export  govt_own size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)


***************************************
*Interaction Effects*
***************************************

***LYS==1 Floats***
use bfw_final, clear
keep if fx_3way_99==1

 oprobit  fx_prob reer_change_98_99  govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)
 oprobit  fx_prob reer_change_98_99  govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact   manufact_change_98  , cluster(country)
 oprobit  fx_prob reer_change_98_99  tradeable govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  tradeable_change_98   , cluster(country)
 oprobit  fx_prob reer_change_98_99  export  govt_own size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99   export_change_98_99    , cluster(country)

***RR Floats***
use bfw_final, clear
keep if   rr_regime_99==3|rr_regime_99==4
drop if country=="Indonesia"

 oprobit  fx_prob reer_change_98_99  govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99       , cluster(country)
 oprobit  fx_prob reer_change_98_99  govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact   manufact_change_98  , cluster(country)
 oprobit  fx_prob reer_change_98_99  tradeable govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  tradeable_change_98   , cluster(country)
 oprobit  fx_prob reer_change_98_99  export  govt_own size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99   export_change_98_99    , cluster(country)


**********************************
******Figure 5 and 6*************
***********************************

************
*Figure 5: differences in predicted probabilities
*************
*Note: Requires Stata package "prgen".
******************
use bfw_final, clear
keep if fx_3way_99==1 		/* use LYS float classification*/
oprobit  fx_prob   govt_own  size  log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact     , cluster(country)
prgen manufact, from(0) to(1) ncases(10) gen(pred)
*.32 vs. .38
keep if predx==0|predx==1

************
*Figure 6: interaction effects, manufacturing vs. non-manufacturing
************
*Note: These graphs require Stata packages "prvalue" and "praccum".
**************************
use bfw_final, clear
keep if fx_3way_99==1
oprobit  fx_prob reer_change_98_99  govt_own  size    log_gdp_97_99   liabilities_97_99   log_fdi_stock_capita_99  manufact   manufact_change_98  , cluster(country)
capture matrix drop manufact manu
forvalues count= -.31(.01).12 {
    prvalue, x(manufact=1 reer_change_98_99 =`count' manufact_change_98 =`count') rest(mean)
    praccum, using(manu) xis(`count') 
}
praccum, using(manu) gen(manufacturing)
capture matrix drop nonmanufact nomanu
forvalues count= -.31(.01).12 {
    prvalue, x(manufact=0 reer_change_98_99 =`count' manufact_change_98 =0) rest(mean)
    praccum, using(nomanu) xis(`count') 
}
praccum, using(nomanu) gen(nonmanufact)
sort manufacturingx

**********************
*The confidence intervalues are generated using Clarify package (Tomz, Wittenberg, and King 2001)*
*************************
estsimp oprobit  fx_prob reer_change_98_99  govt_own  size  log_gdp_97_99 liabilities_97_99 log_fdi_stock_capita_99  manufact manufact_change_98 , cluster(country)
gen cilo= .  /*lower bound of ci*/
gen cihi = .  /*upper bound of ci*/
gen reeraxis = _n+ -32 in 1/43 /*contains range of REER appreciation*/
setx mean	
local a = -32 /*begin with min value of REER appreciation*/
while `a' <= 11 {			
	setx mean 
	setx manufact 1 
	setx reer_change_98_99 `a'/100 manufact_change_98 ((`a'/100)*1) 
	simqi, prval(4) genpr(pi1) 
	_pctile pi1, p(2.5 97.5)
 	replace cilo = r(r1) if reeraxis==`a'
	replace cihi = r(r2) if reeraxis==`a'
	drop pi1
	local a = `a' + 1
}
sort reeraxis
gen reeraxis2=reeraxis/100

*****************
drop b1-b11
estsimp oprobit  fx_prob reer_change_98_99  govt_own  size  log_gdp_97_99 liabilities_97_99 log_fdi_stock_capita_99  manufact manufact_change_98 , cluster(country)
gen nomanucilo= .  /*lower bound of ci*/
gen nomanucihi = .  /*upper bound of ci*/
setx mean	
local a = -32 /*begin with min value of REER appreciation*/
while `a' <= 11 {			
	setx mean 
	setx manufact 0 
	setx reer_change_98_99 `a'/100 manufact_change_98 ((`a'/100)*0) 
	simqi, prval(4) genpr(pi1) 
	_pctile pi1, p(2.5, 97.5)
 	replace nomanucilo = r(r1) if reeraxis==`a'
	replace nomanucihi = r(r2) if reeraxis==`a'
	drop pi1
	local a = `a' + 1
}
sort reeraxis

***********
*Graphs of predicted probabilities and confidence intervals*
twoway (scatter manufacturingp4 manufacturingx)   (rspike cilo cihi reeraxis2), ytitle("Probability of Exchange Rate Problem = 4", size(large)) xtitle("REER Appreciation", size(large))title("Manufacturing Firms")ylabel(,labsize(large))xlabel(,labsize(large))legend(order(1 "predicted probability" 2 "C.I.")size(large))saving("manufact", replace)
twoway (scatter nonmanufactp4 nonmanufactx)(rspike nomanucihi nomanucilo reeraxis2), ytitle("") xtitle("REER Appreciation",size(large))ylabel(,labsize(large))xlabel(,labsize(large))title("Non-Manufacturing Firms")legend(order(1 "predicted probability" 2 "C.I.")size(large))saving("nonmanufact", replace)
graph combine "manufact" "nonmanufact", iscale(.5) ycom  title("LYS Floating Regimes, 1999", size(medium))  scheme(s2mono)
drop b1-b1

**************
log close
clear
exit
